package com.heima.user.controller;



import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dto.AuthDto;
import com.heima.user.service.ApUserRealnameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;


/**
 * APP实名认证信息表(ApUserRealname)表控制层
 *
 * @author makejava
 * @since 2023-06-26 17:57:01
 */

@Api(tags = "用户实名认证接口")
@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController  {
    /**
     * 服务对象
     */
    @Resource
    private ApUserRealnameService apUserRealnameService;

    /**
     *
     * @param font_image 正面证件照
     * @param back_image 背面证件照
     * @param hold_image 手持证件照片
     * @param live_image 活体照
     * @param name   姓名
     * @param idno   证件号
     * @return
     */
    @ApiOperation("用户提交认证信息接口")
    @PostMapping("/submit")
    public ResponseResult submit(MultipartFile font_image,
                                 MultipartFile back_image,
                                 MultipartFile hold_image,
                                 MultipartFile live_image,
                                 String name,
                                 String idno) throws IOException {

        return apUserRealnameService.submit(font_image,back_image,hold_image,live_image,name,idno);
    }

    /**
     * 查询实名认证列表
     * @param dto
     * @return
     */
    @ApiOperation("查询实名认证列表")
    @PostMapping("/list")
    public ResponseResult loadListByStatus(@RequestBody AuthDto dto){
        return apUserRealnameService.queryList(dto);
    }

    /**
     * 审核通过
     * @param dto
     * @return
     */
    @PostMapping(path = "/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto){
        dto.setStatus((short) 9);
        return apUserRealnameService.updateAuthStatus(dto);
    }

    /**
     * 审核失败
     * @param dto
     * @return
     */
    @PostMapping(path = "/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        dto.setStatus((short) 2);
        return apUserRealnameService.updateAuthStatus(dto);
    }




}

